
from fastapi import APIRouter, Query
from typing import Optional

from task import video_requests, download_file

router = APIRouter()

# 采集全部视频数据的接口
@router.get("/collection_all_data")
def get_all_video_data(category: Optional[str] = Query(None, description="视频类别，如果不指定则采集所有类别")):
    """
    采集全部视频数据
    :param category: 视频类别，如果不指定则采集所有类别
    :return:
    """
    video_requests.get_all_video_list(category)

# 采集最新视频数据的接口
@router.get("/collection_new_data")
def get_new_video_data(category: Optional[str] = Query(None, description="视频类别，如果不指定则采集所有类别")):
    """
    采集最新视频数据
    :param category: 视频类别，如果不指定则采集所有类别
    :return:
    """
    video_requests.get_new_video_list(category)

@router.get("/download_video_data")
def download_video_data():
    """
    下载所有视频文件
    :return:
    """
    download_file.download_all_file()